/**
 * Created by LiuDan on 2017/07/22.
 * 登陆模板.js
 */
$(function(){
    function loadCss( url ){
        var link = document.createElement( "link" );
        link.type = "text/css";
        link.rel = "stylesheet";
        link.href = url;
        document.getElementsByTagName( "head" )[0].appendChild( link );
    };
    var linkUrl=basePathOnline+'/home/css/mylogin.css';
    loadCss(linkUrl);
    var a=Math.random();
    var loginAlert={
        login:'<div class="modal" id="login" data-backdrop="static">'+
        '<div class="modal-dialog login-module" role="document">'+
        '<div class="cymylogin">'+
        '<div class="cymylogin-top">'+
        '<div class="cymyloginclose" data-dismiss="modal" aria-label="Close" data-backdrop="static"></div>'+
        '<div class="cymyloginlogo login-register">' +
        '<div class="login-button select">账号登录</div>' +
        '<div class="register-button">手机动态码登录</div>' +
        '</div>'+
        '<div class="cymyloginhint cymlogin"></div>' +
        '</div>'+
        '<div class="cymylogin-bottom form-login login-content"  style="display:block">'+
        '<div class="usernameBox">'+
        '<input type="text" class="cyinput1 form-control userName" maxlength="100" placeholder="请输入手机号" autocomplete="off"/>'+
        '<div class="cymyloginclose1 userNameClose"></div>'+
        '<div class="errorTips">'+
        '<div class="userNameHit wordHit">'+
        '<img src="'+basePathOnline+'/home/img/alter_14.png" alt=""/><span class="HitWord"></span>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '<div class="passwordBox">'+
        '<input type="password" class="cyinput2 form-control password" maxlength="18" placeholder="请输入6-18位密码" autocomplete="off"/>'+
        '<div class="cymyloginclose2 passwordClose"></div>'+
        '<div class="errorTips">'+
        '<div class="passwordHit wordHit">'+
        '<img src="'+basePathOnline+'/home/img/alter_14.png" alt=""/><span class="HitWord"></span>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '<button class="cymyloginbutton goLogin" onclick="">登<em></em>录</button>'+
        '<div class="login-ways clearfix">'+
        '<div class="auto-login">'+
        '<span class="autoLoginSelect"></span><span class="autoLogin">下次自动登录</span>'+
        '<span class="line">|</span>'+
        '<a class="forgetPassword" href="javascript:;">忘记密码？</a>'+
        '</div>'+
        '<a class="imRegister" href="javascript:;">立即注册</a>'+
        '</div>'+
        '</div>'+
        '<div class="cymylogin-bottom moblieLogin register-content" style="display:none">'+
        '<div class="registerUsernameBox">'+
        '<input type="text" class="Rusername"  maxlength="30" placeholder="手机号" autocomplete="off">'+
        '<span class="RusernameClose"></span>'+
        '<div class="errorTips">'+
        '<div class="RuserNameHit wordHit">'+
        '<img src="'+basePathOnline+'/home/img/alter_14.png" alt=""/><span class="HitWord"></span>'+
        '</div>' +
        '</div>'+
        ' </div>' +
        '<div class="imgVertifyCode">' +
        '<input type="text" class="imgVertify"  maxlength="5" placeholder="图形验证码" autocomplete="off">'+
        '<img src="'+basePathOnline+'/captcha/default?t='+a+'"/>'+
        '<div class="errorTips">'+
        '<div class="RverificationCodeHit wordHit">'+
        '  <img src="'+basePathOnline+'/home/img/alter_14.png" alt=""/><span class="HitWord"></span>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '<div class="verification-code clearfix">' +
        '<input type="text" class="verifCode" maxlength="4" placeholder="4位动态码"/>'+
        '<div class="btn-getcode">获取动态码</div>'+
        '<div class="errorTips">'+
        '<div class="RverificationCodeHit wordHit">'+
        '<img src="'+basePathOnline+'/home/img/alter_14.png" alt=""/><span class="HitWord"></span>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '<button class="cymyloginbutton goLoginCode">登<em></em>录</button>'+
        '<div class="registerUserProtocal">'+
        '<span class="allowProtocal"></span><span class="rememberPhone">记住手机号</span>'+
        '<a class="imRegister" href="javascript:;">立即注册</a>'+
        '</div>'+
        '</div>' +
        '<div class="other-login-box">'+
        '<div class="otherway"><hr><span>其它方式登录</span><hr></div>'+
        '<div class="other-login-ways clearfix">'+
        '<div class="qq-login"></div>'+
        ' <div class="weixin-login"></div>'+
        '<div class="weibo-login"></div>'+
        '</div>'+
        '</div>'+
        '</div>' +
        '</div>' +
        '</div>',
    }
    $('body').append(template.compile(loginAlert.login));
    var referUrl=window.location.href;
    $('.imRegister').click(function(){
        window.location.href=basePathOnline+'/home/public/register?refer='+referUrl
    })
    //login js
    function loginFun(){
        var url =basePathOnline+ "/home/js/newLogin.js";
        var script = document.createElement('script');
        script.setAttribute('src', url);
        // 把script标签加入head，此时调用开始
        $(document.getElementsByTagName('head')[0]).prepend(script);
    };
    function thirdLogin(){
        var url = basePathOnline+"/home/js/thirdLogin.js";
        var script = document.createElement('script');
        script.setAttribute('src', url);
        // 把script标签加入head，此时调用开始
        $(document.getElementsByTagName('head')[0]).prepend(script);
    };
    loginFun();
    thirdLogin();
})